﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CADprogram.Base;

namespace CADprogram.Base
{
   public  class Base
    {
        static Matrix matrixFangse = new Matrix();

        static Matrix inv_matrixfangshe = new Matrix();//仿射变换逆变换

        public static Matrix Matrix_Fangse
        {
            get { return matrixFangse; }
            set { matrixFangse = value; }
        }

        public static Matrix Inv_Matrixfangshe
        {
            get { return inv_matrixfangshe; }
            set { inv_matrixfangshe = value; }
        }
        public static void Init()
        {
            matrixFangse.Rotate(-90,MatrixOrder.Append);
            inv_matrixfangshe = matrixFangse.Clone();
            inv_matrixfangshe.Invert();
        }
        public static void SurvyToScreen(float x, float y, out float ox, out float oy)
        {
            ox = 0;
            oy = 0;
            float[] E =matrixFangse.Elements;
            ox = E[0] * x + E[2] * y + E[4];
            oy = E[1] * x + E[3] * y + E[5];
        }
        public static void ScreenTOsurvy(float x, float y, out float ox, out float oy)
        {
            ox = 0;
            oy = 0;
            float[] E = inv_matrixfangshe.Elements;
            ox = E[0] * x + E[2] * y + E[4];
            oy = E[1] * x + E[3] * y + E[5];
        }
    }
}
